/*
 *  Copyright 2020-2025 the original author or authors.
 *  You cannot use this file unless authorized by the author.
 */

package org.ipig.commons.concurrent;

import org.ipig.commons.helper.AssertHelper;
import org.springframework.util.Assert;

/**
 * thread local name
 *
 * @author <a href="mailto:comchnts@163.com">chinats</a>
 * @version $$Id$$
 * @since 1.0
 */
public class ThreadLocalNamed<T> extends ThreadLocal<T> {
    /**
     * name
     */
    private final String name;

    /**
     * @param name String
     */
    public ThreadLocalNamed(String name) {
        AssertHelper.hasText(name, "Name must not be empty");
        this.name = name;
    }

    /**
     * @return String
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return this.name;
    }
}